home *** CD-ROM | disk | FTP | other *** search
Wrap
onClipEvent(load){ function CreateSoldier(xx, zz, Type, Army) { Xpos = xx * FW - zz * FA; Zpos = zz * FD; TotSold++; Shadows.ShadowSample.duplicateMovieClip("SoldShad" + TotSold,TotSold); eval("Shadows.SoldShad" + TotSold)._x = Xpos; eval("Shadows.SoldShad" + TotSold)._y = Zpos; eval("Shadows.SoldShad" + TotSold).gotoAndStop(1); SoldSample.duplicateMovieClip("S" + TotSold,xx + MapW * zz * 4); eval("S" + TotSold).Type = Type; eval("S" + TotSold).Army = Army; eval("S" + TotSold)._x = Xpos; eval("S" + TotSold)._y = Zpos; eval("S" + TotSold).OldPT = 0; eval("S" + TotSold).OldX = eval("S" + TotSold).x = xx; eval("S" + TotSold).OldZ = eval("S" + TotSold).z = zz; eval("S" + TotSold).Shoot1 = new Sound(eval("S" + TotSold)); eval("S" + TotSold).Shoot2 = new Sound(eval("S" + TotSold)); eval("S" + TotSold).Die1 = new Sound(eval("S" + TotSold)); eval("S" + TotSold).Die2 = new Sound(eval("S" + TotSold)); eval("S" + TotSold).Shoot1.attachSound("Shoot1"); eval("S" + TotSold).Shoot2.attachSound("Shoot2"); eval("S" + TotSold).Die1.attachSound("Die1"); eval("S" + TotSold).Die2.attachSound("Die2"); if(eval("S" + TotSold).Type == 1) { eval("S" + TotSold).WalkSpeed = 7; } eval("S" + TotSold).XDM = new Array(eval("S" + TotSold).WalkSpeed * 0.2,eval("S" + TotSold).WalkSpeed,- eval("S" + TotSold).WalkSpeed * 0.2,- eval("S" + TotSold).WalkSpeed,0); eval("S" + TotSold).ZDM = new Array(- eval("S" + TotSold).WalkSpeed * 0.4,0,eval("S" + TotSold).WalkSpeed * 0.4,0,0); Map[zz][xx] = TotSold; eval("S" + TotSold).ind = TotSold; eval("S" + TotSold).Go = true; eval("S" + TotSold).Dead = false; eval("S" + TotSold).Dark = false; eval("S" + TotSold).Follow = false; eval("S" + TotSold).PrevLocX = new Array(); eval("S" + TotSold).PrevLocZ = new Array(); eval("S" + TotSold).dir = random(4); eval("S" + TotSold).Col = new Color(eval("S" + TotSold)); eval("S" + TotSold).CurPos = eval("S" + TotSold).DesPos = random(16) + 1; eval("S" + TotSold).DirPos = new Array(2,5,10,13); eval("S" + TotSold).Pacified = false; eval("S" + TotSold).InAbduction = false; } function CalculateBox(X, Z, XCalc, ZCalc) { var _loc1_ = {x:0,z:0}; if(ZCalc == 1) { _loc1_.z = Math.floor(Z / FD); } if(ZCalc == 2) { _loc1_.z = Math.round(Z / FD); } if(ZCalc == 3) { _loc1_.z = Math.ceil(Z / FD); } if(XCalc == 1) { _loc1_.x = Math.floor((X + _loc1_.z * FA) / FW); } if(XCalc == 2) { _loc1_.x = Math.round((X + _loc1_.z * FA) / FW); } if(XCalc == 3) { _loc1_.x = Math.ceil((X + _loc1_.z * FA) / FW); } return _loc1_; } function Move(MC) { if(MC.xGo > 0) { xCalc = 3; } else { xCalc = 1; } if(MC.zGo > 0) { zCalc = 3; } else { zCalc = 1; } Box = CalculateBox(MC._x + MC.xGo,MC._y + MC.zGo,1,2); if((Map[Box.z][Box.x] == 0 or Map[Box.z][Box.x] > 600 or Map[Box.z][Box.x] == MC.ind) and Box.x >= 0 and Box.x < MapW and Boox.z >= 0 and Box.z < MapD) { MC._x += MC.xGo; MC._y += MC.zGo; eval("Shadows.SoldShad" + MC.ind)._x = MC._x; eval("Shadows.SoldShad" + MC.ind)._y = MC._y; MC.Blocked = false; } else { MC.Blocked = true; } Box = CalculateBox(MC._x,MC._y,1,2); MC.x = Box.x; MC.z = Box.z; if(MC.OldPT >= 0) { Map[MC.OldZ][MC.OldX] = MC.OldPT; } if(Map[MC.z][MC.x] > 300) { MC.OldPT = Map[MC.z][MC.x]; } else { MC.OldPT = 0; } Map[MC.z][MC.x] = MC.ind; MC.OldX = MC.x; MC.OldZ = MC.z; if(MC._y <= MC.z * FD - 5) { Dpt = MC.x + MapW * MC.z * 4; } else { Dpt = MC.x + MapW * (MC.z * 4 + 2); } MC.swapDepths(Dpt); MC.xGo = MC.zGo = 0; } function CheckShadow(MC) { var _loc2_ = {x:0,y:0}; _loc2_.x = MC._x + 17.5; _loc2_.y = MC._y - 7; localToGlobal(_loc2_); if(Shadows.High.hitTest(_loc2_.x,_loc2_.y,true)) { if(!MC.Dark) { MC.Col.setTransform(DarkColor); MC.Dark = true; } } else if(MC.Dark) { MC.Col.setTransform(NormalColor); MC.Dark = false; } } function FindDirection(MC, XTar, ZTar) { XDis = XTar - MC.x; ZDis = ZTar - MC.z; if(Math.abs(XDis) > 2 or Math.abs(ZDis) > 2) { MC.Go = true; PrefDir = new Array(); if(Math.abs(XDis) - Math.abs(ZDis) > 0) { if(XDis > 0) { PrefDir[0] = 1; } else { PrefDir[0] = 3; } if(ZDis > 0) { PrefDir[1] = 2; } else { PrefDir[1] = 0; } } else { if(ZDis > 0) { PrefDir[0] = 2; } else { PrefDir[0] = 0; } if(XDis > 0) { PrefDir[1] = 1; } else { PrefDir[1] = 3; } } PrefDir[2] = PrefDir[1] - 2; PrefDir[3] = PrefDir[0] - 2; if(PrefDir[2] < 0) { PrefDir[2] += 4; } if(PrefDir[3] < 0) { PrefDir[3] += 4; } FinalDir = 4; CycDir = 4; dd = 0; while(dd <= 3) { Cycling = false; dr = PrefDir[dd]; NextX = MC._x + MC.XDM[dr]; NextZ = MC._y + MC.ZDM[dr]; Pt = PointOnMap(NextX,NextZ); if((Pt == 0 or Pt == MC.ind) and dr != MC.BackDir) { j = 0; while(j < MC.PrevLocX.length) { if(Math.abs(NextX - MC.PrevLocX[j]) < 2 and Math.abs(NextZ - MC.PrevLocZ[j]) < 2) { CycDir = dr; Cycling = true; break; } j++; } if(!Cycling) { FinalDir = dr; break; } } dd++; } if(FinalDir == 4) { FinalDir = CycDir; } if(FinalDir == 4) { FinalDir = Mc.BackDir; } MC.BackDir = FinalDir + 2; if(MC.BackDir > 3) { MC.BackDir -= 4; } MC.PrevLocX.push(Math.round(MC._x)); MC.PrevLocZ.push(Math.round(MC._y)); if(MC.PrevLocX.length > 18) { MC.PrevLocX.shift(); MC.PrevLocZ.shift(); } MC.dir = FinalDir; MC.xGo = MC.XDM[FinalDir]; MC.zGo = MC.ZDM[FinalDir]; } else { MC.Go = false; } } function PointOnMap(Xc, Zc) { Bx = CalculateBox(Xc,Zc,1,2); return Map[Bx.z][Bx.x]; } function Shoot(MC, Target) { FreeBull = 0; Xfrom = MC._x + 17.5; Zfrom = MC._y - 7; Xto = Target._x + 17.5; Zto = Target._y - 7; XDis = Math.abs(Xto - Xfrom); ZDis = Math.abs(Zto - Zfrom) * 1.67; Angle = Math.atan(ZDis / XDis); if(Xto > Xfrom) { Xco = 1; } else { Xco = -1; } if(Zto > Zfrom) { Zco = 1; } else { Zco = -1; } Angle += Math.random() * 0.1 - 0.05; XM = Math.cos(Angle) * 20 * Xco; ZM = Math.sin(Angle) * 12 * Zco; jj = 1; while(jj <= TotBull) { if(!eval("B" + jj)._visible) { FreeBull = jj; } jj++; } if(FreeBull == 0) { TotBull++; BulletSample.duplicateMovieClip("B" + TotBull,MC.x + MapW * (MC.z * 4 + 3)); FreeBull = TotBull; } MC.Phase.Body.Fire1.play(); MC.Phase.Body.Fire2.play(); Volume = 100 - Math.abs(UFO.Boxx - MC.x) - Math.abs(UFO.Boxz - MC.z); Pan = (MC.x - UFO.Boxx) * 3; if(Pan > 100) { Pan = 100; } if(Pan < -100) { Pan = -100; } if(Volume < 0) { Volume = 0; } if(random(2) == 0) { MC.Shoot1.setVolume(Volume); MC.Shoot1.setPan(Pan); MC.Shoot1.start(); } else { MC.Shoot2.setVolume(Volume); MC.Shoot2.setPan(Pan); MC.Shoot2.start(); } eval("B" + FreeBull).active = true; eval("B" + FreeBull)._x = Xfrom + XM * 4; eval("B" + FreeBull)._y = Zfrom + ZM * 4; eval("B" + FreeBull).xMove = XM; eval("B" + FreeBull).zMove = ZM; } function MoveBullets() { ii = 1; while(ii <= TotBull) { if(eval("B" + ii).active) { if(Math.abs(eval("B" + ii)._x - S299._x) > 780 or Math.abs(eval("B" + ii)._y - S299._y) > 610) { eval("B" + ii)._visible = false; } else { eval("B" + ii)._visible = true; } eval("B" + ii)._x += eval("B" + ii).xMove; eval("B" + ii)._y += eval("B" + ii).zMove; Box = CalculateBox(eval("B" + ii)._x,eval("B" + ii)._y,1,1); if(Box.x >= MapW or Box.x < 0 or Box.z >= MapD or Box.z < 0) { eval("B" + ii).active = false; } else if(Map[Box.z][Box.x] >= 300 and Map[Box.z][Box.x] < 400) { eval("B" + ii).active = false; } xx = Box.x - 1; while(xx <= Box.x + 1) { zz = Box.z - 1; while(zz <= Box.z + 1) { if(Map[zz][xx] > 0 and Map[zz][xx] < 300) { if(eval("B" + ii)._x > eval("S" + Map[zz][xx])._x and eval("B" + ii)._x < eval("S" + Map[zz][xx])._x + FW and eval("B" + ii)._y < eval("S" + Map[zz][xx])._y and eval("B" + ii)._y > eval("S" + Map[zz][xx])._y - 20 and !eval("S" + Map[zz][xx]).InAbduction) { eval("B" + ii).active = false; eval("S" + Map[zz][xx]).Dead = true; if(!eval("S" + Map[zz][xx]).Pacified) { FindPhase(eval("S" + Map[zz][xx])); } if(Math.abs(eval("B" + ii).xMove) > Math.abs(eval("B" + ii).zMove * 2.5)) { Horizontal = true; } else { Horizontal = false; } if(Horizontal) { if(eval("B" + ii).xMove > 0) { eval("S" + Map[zz][xx]).Phase.Body.gotoAndPlay(25); eval("Shadows.SoldShad" + Map[zz][xx]).Body.gotoAndPlay(9); } else { eval("S" + Map[zz][xx]).Phase.Body.gotoAndPlay(39); eval("Shadows.SoldShad" + Map[zz][xx]).Body.gotoAndPlay(23); } } else if(eval("B" + ii).zMove > 0) { eval("S" + Map[zz][xx]).Phase.Body.gotoAndPlay(32); eval("Shadows.SoldShad" + Map[zz][xx]).Body.gotoAndPlay(16); } else { eval("S" + Map[zz][xx]).Phase.Body.gotoAndPlay(18); eval("Shadows.SoldShad" + Map[zz][xx]).Body.gotoAndPlay(2); } eval("S" + Map[zz][xx]).swapDepth(eval("S" + Map[zz][xx]).x + MapW * eval("S" + Map[zz][xx]).z * 4 + MapW); if(!eval("S" + Map[zz][xx]).Pacified and TotSold < MaxSold) { LocateNewSoldier(eval("S" + Map[zz][xx]).Type,eval("S" + Map[zz][xx]).Army); } DVolume = 100 - Math.abs(UFO.Boxx - eval("S" + Map[zz][xx]).x) - Math.abs(UFO.Boxz - eval("S" + Map[zz][xx]).z); DPan = (eval("S" + Map[zz][xx]).x - UFO.Boxx) * 3; if(DVolume < 0) { DVolume = 0; } if(DPan > 100) { DPan = 100; } if(DPan < -100) { DPan = -100; } if(random(2) == 0) { eval("S" + Map[zz][xx]).Die1.setVolume(DVolume); eval("S" + Map[zz][xx]).Die1.setPan(DPan); eval("S" + Map[zz][xx]).Die1.start(); } else { eval("S" + Map[zz][xx]).Die2.setVolume(DVolume); eval("S" + Map[zz][xx]).Die2.setPan(DPan); eval("S" + Map[zz][xx]).Die2.start(); } _parent.Panel.Dead = _parent.Panel.Dead + 1; if(eval("S" + Map[zz][xx]).Pacified) { _parent.Panel.Pacified--; } ReduceAlive(); Map[zz][xx] = 666; } } zz++; } xx++; } eval("B" + ii).swapDepths(Box.x + MapW * (Box.z * 4 + 3)); } else { eval("B" + ii)._visible = false; } ii++; } } function Spin(MC) { if(MC.CurPos == MC.DesPos) { return true; } MC.Phase.gotoAndStop(5); SpinAmpl = MC.DesPos - MC.CurPos; SpinDir = SpinAmpl / Math.abs(SpinAmpl); if(Math.abs(SpinAmpl) > 8) { SpinDir = - SpinDir; } MC.CurPos += SpinDir; if(MC.CurPos > 16) { MC.CurPos -= 16; } if(MC.CurPos < 1) { MC.CurPos += 16; } MC.Phase.Body.gotoAndStop(MC.CurPos); return false; } function CalcDir(From, To) { XDis = Math.abs(To._x - From._x); ZDis = Math.abs(To._y - From._y) / 0.4; Angle = Math.atan(ZDis / XDis); if(To._x >= From._x and To._y < From._y) { Angle = HalfPI - Angle; } if(To._x >= From._x and To._y >= From._y) { Angle = HalfPI + Angle; } if(To._x < From._x and To._y >= From._y) { Angle = 3.141592653589793 + HalfPI - Angle; } if(To._x < From._x and To._y < From._y) { Angle = 3.141592653589793 + HalfPI + Angle; } Phase = Math.round(Angle * 8 / 3.141592653589793) + 1; if(Phase > 16) { Phase -= 16; } return Phase; } function FindPhase(MC) { if(MC.CurPos == 16 or MC.CurPos <= 3) { MC.Phase.gotoAndStop(1); } if(MC.CurPos >= 4 and MC.CurPos <= 7) { MC.Phase.gotoAndStop(2); } if(MC.CurPos >= 8 and MC.CurPos <= 11) { MC.Phase.gotoAndStop(3); } if(MC.CurPos >= 12 and MC.CurPos <= 15) { MC.Phase.gotoAndStop(4); } } function AbductSold(MC) { ActivateColumn(false); eval("Shadows.SoldShad" + MC.ind)._visible = false; _parent.Panel.Pacified = _parent.Panel.Pacified + 1; if(TotSold < MaxSold) { LocateNewSoldier(MC.Type,MC.Army); } _parent.Score += _parent.level * 10; ReduceAlive(); } function ReduceAlive() { if(_parent.Panel.Pacified + _parent.Panel.Dead == MaxSold) { _parent.Pacified = _parent.Panel.Pacified; _parent.Dead = _parent.Panel.Dead; _quality = "HIGH"; _parent.InProcess = false; if(_parent.Pacified >= _parent.LevelLimit[_parent.level - 1]) { _parent.Bonus = _parent.level * (_parent.LevelLimit[_parent.level - 1] * 25 + (_parent.Pacified - _parent.LevelLimit[_parent.level - 1]) * 50); if(_parent.level == _parent.LastLevel) { _parent.Bonus += _parent.Lives * 2500; } else { _parent.Lives = _parent.Lives + 1; } _parent.Score += _parent.Bonus; if(_parent.level < _parent.LastLevel) { _parent.gotoAndStop(6); } else { _parent.Passed = true; _parent.gotoAndStop(8); } } else { _parent.Lives = _parent.Lives - 1; _parent.gotoAndStop(7); } } } function ActivateColumn(Switch) { if(Switch) { UFO.snd.start(); Column._visible = true; Column._x = UFO.x; Column._y = UFO.z; Column.swapDepths(UFO.Boxx + MapW * ((UFO.Boxz + 2) * 4 + 3)); Shadows.High.UFOShadow.gotoAndPlay(2); UFO.Active = false; } else { UFO.Active = true; Column._visible = false; Shadows.High.UFOShadow.gotoAndStop(1); } } function UpdateSlots() { UFO.FreeSlots = 0; i = 1; while(i <= 3) { if(UFO.AbdSold[i - 1] > 0) { eval("_parent.Panel.Light" + i).gotoAndStop(2); } else { eval("_parent.Panel.Light" + i).gotoAndStop(1); UFO.FreeSlots = UFO.FreeSlots + 1; } i++; } if(UFO.FreeSlots == 0) { _parent.Panel.Light5.gotoAndStop(3); } else { _parent.Panel.Light5.gotoAndStop(1); } } function LocateSoldierVertically(Type, Army) { var _loc1_ = {x:0,y:0}; Found = false; if(Army == 1) { Xloc = 0; } else { Xloc = MapW - 1; } InitZloc = random(MapD); offset = 0; while(offset < MapD) { Sign = -1; while(Sign <= 1) { Zloc = InitZloc + offset * Sign; if(Map[Zloc][Xloc] == 0 and Zloc < MapD and Zloc >= 0) { _loc1_.x = Xloc * FW - Zloc * FA; _loc1_.y = Zloc * FD; localToGlobal(_loc1_); if(_loc1_.x < 0 or _loc1_.x > 585 or _loc1_.y < 0 or _loc1_.y > 420) { CreateSoldier(Xloc,Zloc,Type,Army); Found = true; } } if(Found) { break; } Sign += 2; } if(Found) { break; } offset++; } return Found; } function LocateSoldierHorizontally(Type, Army) { var _loc1_ = {x:0,y:0}; Found = false; if(Army == 1) { Zloc = 0; } else { Zloc = MapD - 1; } InitXloc = random(MapW); offset = 0; while(offset < MapW) { Sign = -1; while(Sign <= 1) { Xloc = InitXloc + offset * Sign; if(Map[Zloc][Xloc] == 0 and Xloc < MapW and Xloc >= 0) { _loc1_.x = Xloc * FW - Zloc * FA; _loc1_.y = Zloc * FD; localToGlobal(_loc1_); if(_loc1_.x < 0 or _loc1_.x > 585 or _loc1_.y < 0 or _loc1_.y > 420) { CreateSoldier(Xloc,Zloc,Type,Army); Found = true; } } if(Found) { break; } Sign += 2; } if(Found) { break; } offset++; } return Found; } function LocateNewSoldier(Type, Army) { if(random(2) == 0) { Found = LocateSoldierVertically(Type,Army); if(!Found) { Found = LocateSoldierHorizontally(Type,Army); } } else { Found = LocateSoldierHorizontally(Type,Army); if(!Found) { Found = LocateSoldierVertically(Type,Army); } } if(!Found) { CreateSoldier(random(MapW),random(MapD),Type,Army); } } _parent.InProcess = true; STC = FramesSummary = 0; SpeedTest = true; _quality = "HIGH"; Paused = false; _parent.Bonus = 0; Map = eval("_parent.level" + _parent.level); Rad2Deg = 57.29577951308232; HalfPI = 1.5707963267948966; MapD = Map.length; MapW = Map[0].length; FW = 35; FD = 14; FA = 7; MaxSold = _parent.LevelMax[_parent.level - 1]; TotSold = 0; TotBull = 0; UFO = new Object(); UFO.XSpeed = 0; UFO.ZSpeed = 0; UFO.Active = true; UFO.AbdSold = new Array(0,0,0); UFO.Ready = new Array(false,false,false); UFO.ReadyNum = 0; UFO.FreeSlots = 3; UFO.snd = new Sound(this); UFO.snd.attachSound("UFO"); RejSound = new Sound(); RejSound.attachSound("NO"); _parent.Pacified = _parent.Panel.Pacified = 0; _parent.Dead = _parent.Panel.Dead = 0; Box = new Object(); var DarkColor = {ra:110,rb:-50,ga:110,gb:-50,ba:110,bb:-50,aa:100,ab:0}; var NormalColor = {ra:100,rb:0,ga:100,gb:0,ba:100,bb:0,aa:100,ab:0}; this.beginFill(3711834); this.moveTo(0,0); this.lineTo(MapW * FW,0); this.lineTo(MapW * FW - MapD * FA,MapD * FD); this.lineTo(- MapD * FA,MapD * FD); this.lineTo(0,0); this.endFill(); Shadows._x = Shadows._y = Shadows.High._x = Shadows.High._y = 0; zz = 0; while(zz < MapD) { xx = 0; while(xx < MapW) { Dpt = xx + MapW * zz * 4; Xpos = xx * FW - zz * FA; Zpos = zz * FD; if(Map[zz][xx] > 0 and Map[zz][xx] < 300) { CreateSoldier(xx,zz,Map[zz][xx] % 100,Math.floor(Map[zz][xx] / 100)); } if(Map[zz][xx] > 300) { Kind = Map[zz][xx] % 100; if(Kind > 0) { TreeSample.duplicateMovieClip("Obj" + xx + "x" + zz,Dpt + MapW); eval("Obj" + xx + "x" + zz).gotoAndStop(Kind); eval("Obj" + xx + "x" + zz)._x = Xpos; eval("Obj" + xx + "x" + zz)._y = Zpos; if(Kind <= 5) { Shadows.High.ShadowSample.duplicateMovieClip("Shad" + xx + "x" + zz,xx + MapW * zz); eval("Shadows.High.Shad" + xx + "x" + zz)._x = Xpos; eval("Shadows.High.Shad" + xx + "x" + zz)._y = Zpos; eval("Shadows.High.Shad" + xx + "x" + zz).gotoAndStop(2 + random(5)); } else { Shadows.ShadowSample.duplicateMovieClip("Shad" + xx + "x" + zz,xx + MapW * zz); eval("Shadows.Shad" + xx + "x" + zz)._x = Xpos; eval("Shadows.Shad" + xx + "x" + zz)._y = Zpos; eval("Shadows.Shad" + xx + "x" + zz).gotoAndStop(1 + Kind); } } } xx++; } zz++; } SoldSample._visible = false; TreeSample._visible = false; BulletSample._visible = false; Shadows.ShadowSample._visible = false; Shadows.High.ShadowSample._visible = false; Column._visible = false; UpdateSlots(); LX = MapW / 2; LZ = MapD / 2; XP = LX * FW - LZ * FA; ZP = LZ * FD; _X = (585 - XP) / 2; _Y = (520 - ZP) / 2; }